<?php
// include 
include 'library.php';
include 'conf.php';

// 获取session是否存在
$noSession = null == getsession('token_openid') || getsession('token_openid') == '';

// 第一次访问：如果没有session，并且没有openid参数，则跳转取openid
if ($noSession && get('token_openid') == '') {
  echo "<script>location.href='http://hm-weauth-node.sgboke.com/enter?platform=game';</script>"; 
  exit;
} 

// 第二次以后的访问：当前确认带参返回，加session，跳转到当前页，并去除openid参数
if ($noSession) {
  setsession('token_openid', get('token_openid'));
  header('location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
  exit;
}
